<?php
session_start();
$UserID = trim($_SESSION['user_id']);
	if($UserID == "")
	{
		$UserID = session_id();
		//$_SESSION['user_id'] = $UserID;
	}
//echo "Welcome: " . $UserID;
$edit_id_item = $_GET['_e'];
$tr = isset($_GET['tr']) ? intval($_GET['tr']) : 0;
$title_reference_key = $tr;
$title_reference_id = "";
if($tr != 0) {
	$sql = "SELECT * FROM tbl_references WHERE User='".$UserID."' AND ID='".$tr."'";
	$res = mysql_query($sql);
	$result = mysql_fetch_assoc($res);
	$title_reference_id = $result['ID'];
	$title_reference = $result['Title_Reference'];
	$_SESSION['tr_dload'] = $title_reference_id;
} else {
	$sql = "SELECT * FROM tbl_references WHERE User='".$UserID."' ORDER BY CreatedDate DESC LIMIT 1";
	$res = mysql_query($sql);
	$result = mysql_fetch_assoc($res);
	$num = mysql_num_rows($res);
	if($num == 1) {
		$title_reference_id = $result['ID'];
		$title_reference = $result['Title_Reference'];
		$_SESSION['tr_dload'] = $title_reference_id;
	} else {
		$d = date("Y-m-d H:i:s");
		$sql2 = "INSERT INTO tbl_references SET Title_Reference='Untitled references', User='".$UserID."', CreatedDate='".$d."', UpdatedDate='".$d."'";
		$res2 = mysql_query($sql2);
		$title_reference = "Untitled References";	
		$title_reference_id = mysql_insert_id();
		$_SESSION['tr_dload'] = $title_reference_id;
	}
}

if(isset($_GET['del']))
{
	$del=mysql_query("delete from composedocument where id='".$_GET['del']."'");
	if($del)
	echo "<script>location.href='index.php?page=assignment_manager';</script>";
}
?>
<style type="text/css">
a.image
{
	text-decoration:none!important;
	 color: #0488B9;
    font-family: Arial;
    font-size: 13px;
    font-weight: bold;
    
	
}
a.image:hover
{
	text-decoration:none!important;
	 color: #000;
    font-family: Arial;
    font-size: 13px;
    font-weight: bold;
    text-decoration: none;
	
}
.mandatory_field1
{
	border:#F00 solid 1px;
}
</style>
<script language="javascript">
<?php
	$true_host = $_SERVER['HTTP_HOST'];
	echo 'var true_uri ="http://'.$true_host.'";';
?>
var citationList = "";
var citationToInsert = "";
var edit_id_item = '<?php echo $edit_id_item?>';

function sendEmailToMe(assignment_id, tr)
{
	if (assignment_id)
	{
		var url = "email_file_assigment.php?assignment_id=" + assignment_id + "&tr=" + tr;	
		$("#loadingDataAjax").fadeIn();
		$.get(url, function(args){
			if (args == "false")
			{
				alert("Please login before send email");
			}
			else if (args == "-1")
			{
				alert("Your assigment was not found");
			}
			else
			{
				alert("Your request was sent to your email");
			}
			$("#loadingDataAjax").fadeOut();
		});
	}
	else
	{
		alert("Your assignment was not found");
	}
}

function saveMultiBooks()
{
	$.post('/view/assigment_manager_functions.php?tr=<?php echo $title_reference_id; ?>', 
		 { 
			SaveMultiBooks : "SaveMultiBooks",
			dataMultiBook: $("#dataMultiBook").val()
		 },
		 function(args){
			if (args == "true")
			{
				$("#booksresult").html("<span style='color: #2964BA; font-weight:bold; font-style:italic'>Your reference has been generated</span>");				
				reloadReferencesList();
			}
			else
			{
				$("#booksresult").html("<span style='color: red; font-weight:bold; font-style:italic'>Your reference has not been generated.</span>");
			}
		 });
}

function reloadReferencesList()
{
	var tr = "";
	if ('<?php echo $title_reference_id; ?>' != "0")
	{
		tr = 'tr=<?php echo $title_reference_id; ?>';
	}
	$.get(true_uri+'/view/citation_list.php?' + tr, function(data) {
		$('#reference').html(data);
	});
}

function generateBookAuto()
{
	$("#booksresult").show();
	$('#first').hide();
	$('#second').show();
	$('#bookinfo').hide();
	clearFormValidateBook();
}

function generateBookManually()
{
	$("#booksresult").hide();
	$('#first').show();
	$('#second').hide();
	$('#bookinfo').show();
	clearFormValidateBook();
}

function delete_assignment(id, tag)
{
	if (confirm('Do you want to delete this assignment?'))
	{
		$.post("application/action.php", 
			{module : 'delete_assignment', assignment_id : id}, 
			function(data){
				if (data == "1")
				{
					var trCurrent = tag.parentNode.parentNode;
					var trNext = trCurrent.nextSibling;
					if (trNext.tagName == "TR")
					{
						$(trNext).remove();
					}
					else
					{										
						$(trNext.nextSibling).remove();
					}
					$(trCurrent).remove();
				}
			}
		);
	}	
}

function booksearchKeyPress(e)
{
	if (!e)
		e = window.event;
	
	if (e.keyCode == 13)
	{
		$("#btnFindBook").click();
		return false;
	}
	return true;
}

$(function(){
	$("#titleArticleSearch").keypress(function(e){
		if (!e)
			e = window.event;
		if (e.keyCode == 13)
		{
			searchJournal();
			return false;
		}
	});
});

function searchJournal()
{		
	if ($("#titleArticleSearch").val() != "")
	{
		$("#loadingDataAjax").fadeIn();
		$.getJSON('/journaldata/search.php?type=journal&text=' + escape($("#titleArticleSearch").val()),
			function(e){								
				$("#loadingDataAjax").fadeOut();
				if (e && e.titleOfArticle)
				{
					$("#title2").val(e.titleOfArticle);
					$("#journal2").val(e.titleOfJournal);
					$("#edition2").val(e.volumeNumber);
					$("#date2").val(e.year);
					$("#firstname2").val(e.firstName);
					$("#lastname2").val(e.lastName);
					if (e.suggues_link && e.suggues_link.length > 1)
					{
						var text = "";
						text +="<div class='header-relevant'>";
						text +="<div class='header-relevant-title'>";
						text +="<span>Results:<span class='relevant-keyword'>" + $("#titleArticleSearch").val() + "</span></span>";
						text +="</div>";
						text +="<div class='header-relevant-button'>";
						text +="<input type='button' value='Close' onclick='$(this.parentNode.parentNode.parentNode).fadeOut()'/>";
						text +="</div>";
						text +="<div style='clear:both'></div>";
						text +="</div>";			
						text +="<div class='content-relevant'>";
						text +="<span style='font-style:italic;font-weight:bold;display:block;margin-bottom:12px'>Is this the article you were looking for?</span>";
						text +="<p class='item'><a href='" + e.suggues_link[1] + "' target='_blank'>" + e.suggues_link[0] + "</a><br/><span>" + e.suggues_link[1].substring(0, 35) + "...</span></p>";
						text +="</div>";
						$("#divEmptyData").html(text).addClass("relevantAssigment").fadeIn();
					}
					else
					{
						$("#divEmptyData").html("").fadeOut();
					}
				}
				else				
				{
					alert("Journal was not found");
				}
				
			}
		);
	}
	else
	{
		alert("Please enter your journal title");
		$("#titleArticleSearch").focus();
	}
}

function validate1(form)
{
	var num=/^[0-9-]+$/;
	var name =/^[a-zA-Z. ]+$/;
	var title1 = $("#title1");
	var pub1 = $("#pub1");
	var pcity1 = $("#pcity1");
	var date1 = $("#date1");	
	var pub1 = $("#pub1");
	var firstName1 = $("#firstname1");
	var lastName1 = $("#lastname1");
	var isValid = true;
	if (title1.val() == "")
	{
		isValid = false;
		title1.addClass("invalid");
	}
	else
	{
		title1.removeClass("invalid");
	}

	if (pub1.val() == "")
	{
		isValid = false;
		pub1.addClass("invalid");
	}
	else
	{
		pub1.removeClass("invalid");
	}

	if (pcity1.val() == "")
	{
		isValid = false;
		pcity1.addClass("invalid");
	}
	else
	{
		pcity1.removeClass("invalid");
	}

	if (date1.val() == "")
	{
		isValid = false;
		date1.addClass("invalid");
	}
	else
	{
		date1.removeClass("invalid");
	}
	
	if (firstName1.val() == "")
	{
		isValid = false;
		firstName1.addClass("invalid");
	}
	else
	{
		firstName1.removeClass("invalid");
	}

	if (lastName1.val() == "")
	{
		isValid = false;
		lastName1.addClass("invalid");
	}
	else
	{
		lastName1.removeClass("invalid");
	}

	//check valid multi author
	var tbl = document.getElementById('dataTable1');
	for(var i = 0; i < tbl.rows.length; i++)
	{
		var row = tbl.rows[i];
		var inputs = $(row).find(":text");
		if (inputs.length == 2)
		{
			if (inputs[0].value == "" && inputs[1].value != "")
			{
				isValid = false;
				$(inputs[0]).addClass("invalid");
				$(inputs[1]).removeClass("invalid");
			}
			else if (inputs[0].value != "" && inputs[1].value == "")
			{
				isValid = false;
				$(inputs[0]).removeClass("invalid");
				$(inputs[1]).addClass("invalid");			
			}
			else
			{
				$(inputs[0]).removeClass("invalid");
				$(inputs[1]).removeClass("invalid");
			}		
		}
	}

	if (!isValid)
	{
		$("#book_error_notice").fadeIn();
	}
	else
	{
		$("#book_error_notice").fadeOut();
		
		saveBookGenerate('', true);
	}

	return false;
}

function saveBookGenerate(isbn, isSaveManually)
{
	$.post('/view/assigment_manager_functions.php?tr=<?php echo $title_reference_key; ?>&_e=' + edit_id_item, 
		 $("#form1").serialize() + "&SubmitBook=SubmitBook&isbn=" + isbn,
		 function(args){
			if (args == "true")
			{
				edit_id_item = "";
				$("#bookinfoResult").html("<span style='color: #2964BA; font-weight:bold; font-style:italic'>Your reference has been generated</span>");				
				reloadReferencesList();
				if (isSaveManually)
				{
					$("#booksresult").hide();
					$("#bookinfoResult").html("Your reference has been generated");
					$("#booksresult").html("");					
				}
				else
				{
					$("#booksresult").show();
					$("#booksresult").html("Your reference has been generated");
					$("#bookinfoResult").html("");
				}
				
				
				$("#booksearch").val("");
				
				clearFormValidateBook();
				clearAndKeepOneRow('dataTable1');
			}
			else
			{
				alert("Your reference has been generated fail " + args);
			}
		 });
}

function clearFormValidateBook()
{
	var title1 = $("#title1");
	var pub1 = $("#pub1");
	var pcity1 = $("#pcity1");
	var date1 = $("#date1");
	var pages1 = $("#pages1");
	var pub1 = $("#pub1");
	var firstname1 = $("#firstname1");
	var lastname1 = $("#lastname1");

	title1.removeClass("invalid").val("");
	pub1.removeClass("invalid").val("");
	pcity1.removeClass("invalid").val("");
	date1.removeClass("invalid").val("");
	pages1.removeClass("invalid").val("");
	firstname1.removeClass("invalid").val("");
	lastname1.removeClass("invalid").val("");	
	$("#book_error_notice").hide();
}

function clearFormValidateJournal()
{
	var title2 = $("#title2");
	var journal2 = $("#journal2");
	var edition2 = $("#edition2");
	var issue2 = $("#issue2");
	var date2 = $("#date2");
	var pages2 = $("#pages2");
	var digital2 = $("#digital2");	
	var firstname2 = $("#firstname2");
	var lastname2 = $("#lastname2");

	title2.removeClass("invalid").val("");
	journal2.removeClass("invalid").val("");
	edition2.removeClass("invalid").val("");
	issue2.removeClass("invalid").val("");
	date2.removeClass("invalid").val("");
	pages2.removeClass("invalid").val("");
	digital2.removeClass("invalid").val("");
	firstname2.removeClass("invalid").val("");
	lastname2.removeClass("invalid").val("");	
	$("#journal_error_notice").hide();
}

function clearFormValidateWebsite()
{
	var name_of_webpage = $("#name_of_webpage");
	var name_of_website = $("#name_of_website");
	var website_year = $("#website_year");
	var website_month = $("#website_month");
	var website_day = $("#website_day");
	var website_year_accessed = $("#website_year_accessed");
	var website_month_accessed = $("#website_month_accessed");	
	var website_day_accessed = $("#website_day_accessed");
	var website_url = $("#website_url");
	var firstname3 = $("#firstname3");
	var lastname3 = $("#lastname3");

	name_of_webpage.removeClass("invalid").val("");
	name_of_website.removeClass("invalid").val("");
	website_year.removeClass("invalid").val("");
	website_month.removeClass("invalid").val("");
	website_day.removeClass("invalid").val("");
	website_year_accessed.removeClass("invalid").val("");
	website_month_accessed.removeClass("invalid").val("");
	website_day_accessed.removeClass("invalid").val("");
	website_url.removeClass("invalid").val("");	
	firstname3.removeClass("invalid").val("");	
	lastname3.removeClass("invalid").val("");	
	$("#website_error_notice").hide();
}

function validate2()
{
	var num=/^[0-9-]+$/;
	var name =/^[a-zA-Z. ]+$/;
	var title1 = $("#title2");
	var journal2 = $("#journal2");
	var date2 = $("#date2");
	var pages2 = $("#pages2");	
	var firstName1 = $("#firstname2");
	var lastName1 = $("#lastname2");
	var isValid = true;
	if (title1.val() == "")
	{
		isValid = false;
		title1.addClass("invalid");
	}
	else
	{
		title1.removeClass("invalid");
	}

	if (journal2.val() == "")
	{
		isValid = false;
		journal2.addClass("invalid");
	}
	else
	{
		journal2.removeClass("invalid");
	}

	if (date2.val() == "")
	{
		isValid = false;
		date2.addClass("invalid");
	}
	else
	{
		date2.removeClass("invalid");
	}

	if (pages2.val() == "")
	{
		isValid = false;
		pages2.addClass("invalid");
	}
	else
	{
		pages2.removeClass("invalid");
	}	

	if (firstName1.val() == "")
	{
		isValid = false;
		firstName1.addClass("invalid");
	}
	else
	{
		firstName1.removeClass("invalid");
	}

	if (lastName1.val() == "")
	{
		isValid = false;
		lastName1.addClass("invalid");
	}
	else
	{
		lastName1.removeClass("invalid");
	}

	//check valid multi author
	var tbl = document.getElementById('dataTable2');
	for(var i = 0; i < tbl.rows.length; i++)
	{
		var row = tbl.rows[i];
		var inputs = $(row).find(":text");
		if (inputs.length == 2)
		{
			if (inputs[0].value == "" && inputs[1].value != "")
			{
				isValid = false;
				$(inputs[0]).addClass("invalid");
				$(inputs[1]).removeClass("invalid");
			}
			else if (inputs[0].value != "" && inputs[1].value == "")
			{
				isValid = false;
				$(inputs[0]).removeClass("invalid");
				$(inputs[1]).addClass("invalid");			
			}
			else
			{
				$(inputs[0]).removeClass("invalid");
				$(inputs[1]).removeClass("invalid");
			}		
		}
	}

	if (!isValid)
	{
		$("#journal_error_notice").fadeIn();
	}
	else
	{
		$("#journal_error_notice").fadeOut();
		
		$.post('/view/assigment_manager_functions.php?tr=<?php echo $title_reference_key; ?>&_e=' + edit_id_item, 
		 $("#form2").serialize() + "&SubmitJournal=SubmitJournal",
		 function(args){
			if (args == "true")
			{
				edit_id_item = "";
				$("#journalInfoResult").html("<span style='color: #2964BA; font-weight:bold; font-style:italic'>Your reference has been generated</span>");
				clearFormValidateJournal();
				clearAndKeepOneRow('dataTable2');
				reloadReferencesList();
			}
			else
			{
				$("#journalInfoResult").html("<span style='color: red; font-weight:bold; font-style:italic'>Your reference has not been generated.</span>");
			}
		 });
	}

	return false;
		
}

function validate3()
{
	var num=/^[0-9-]+$/;
	var name =/^[a-zA-Z. ]+$/;
	var name_of_webpage = $("#name_of_webpage");
	var name_of_website = $("#name_of_website");
	var website_year = $("#website_year");
	var website_month = $("#website_month");	
	var website_day = $("#website_day");
	var website_year_accessed = $("#website_year_accessed");
	var website_month_accessed = $("#website_month_accessed");
	var website_day_accessed = $("#website_day_accessed");
	var website_url = $("#website_url");
	var firstName1 = $("#firstname3");
	var lastName1 = $("#lastname3");
	var isValid = true;
	if (name_of_webpage.val() == "")
	{
		isValid = false;
		name_of_webpage.addClass("invalid");
	}
	else
	{
		name_of_webpage.removeClass("invalid");
	}

	if (name_of_website.val() == "")
	{
		isValid = false;
		name_of_website.addClass("invalid");
	}
	else
	{
		name_of_website.removeClass("invalid");
	}

	if (website_year.val() == "")
	{
		isValid = false;
		website_year.addClass("invalid");
	}
	else
	{
		website_year.removeClass("invalid");
	}

	if (website_month.val() == "")
	{
		isValid = false;
		website_month.addClass("invalid");
	}
	else
	{
		website_month.removeClass("invalid");
	}
	
	if (website_day.val() == "")
	{
		isValid = false;
		website_day.addClass("invalid");
	}
	else
	{
		website_day.removeClass("invalid");
	}
	
	if (website_year_accessed.val() == "")
	{
		isValid = false;
		website_year_accessed.addClass("invalid");
	}
	else
	{
		website_year_accessed.removeClass("invalid");
	}
	
	if (website_month_accessed.val() == "")
	{
		isValid = false;
		website_month_accessed.addClass("invalid");
	}
	else
	{
		website_month_accessed.removeClass("invalid");
	}
	
	if (website_month.val() == "")
	{
		isValid = false;
		website_month.addClass("invalid");
	}
	else
	{
		website_month.removeClass("invalid");
	}
	
	if (website_day_accessed.val() == "")
	{
		isValid = false;
		website_day_accessed.addClass("invalid");
	}
	else
	{
		website_day_accessed.removeClass("invalid");
	}
	
	if (website_url.val() == "")
	{
		isValid = false;
		website_url.addClass("invalid");
	}
	else
	{
		website_url.removeClass("invalid");
	}

	if (firstName1.val() == "")
	{
		isValid = false;
		firstName1.addClass("invalid");
	}
	else
	{
		firstName1.removeClass("invalid");
	}

	if (lastName1.val() == "")
	{
		isValid = false;
		lastName1.addClass("invalid");
	}
	else
	{
		lastName1.removeClass("invalid");
	}

	//check valid multi author
	var tbl = document.getElementById('dataTable3');
	for(var i = 0; i < tbl.rows.length; i++)
	{
		var row = tbl.rows[i];
		var inputs = $(row).find(":text");
		if (inputs.length == 2)
		{
			if (inputs[0].value == "" && inputs[1].value != "")
			{
				isValid = false;
				$(inputs[0]).addClass("invalid");
				$(inputs[1]).removeClass("invalid");
			}
			else if (inputs[0].value != "" && inputs[1].value == "")
			{
				isValid = false;
				$(inputs[0]).removeClass("invalid");
				$(inputs[1]).addClass("invalid");			
			}
			else
			{
				$(inputs[0]).removeClass("invalid");
				$(inputs[1]).removeClass("invalid");
			}		
		}
	}

	if (!isValid)
	{
		$("#website_error_notice").fadeIn();
	}
	else
	{
		$("#website_error_notice").fadeOut();
		
		$.post('/view/assigment_manager_functions.php?tr=<?php echo $title_reference_key; ?>&_e=' + edit_id_item, 
		 $("#form3").serialize() + "&Submitwebsite=Submitwebsite",
		 function(args){
			if (args == "true")
			{
				edit_id_item = "";
				$("#websiteInfoResult").html("<span style='color: #2964BA; font-weight:bold; font-style:italic'>Your reference has been generated</span>");
				clearFormValidateWebsite();
				clearAndKeepOneRow('dataTable3');
				reloadReferencesList();
			}
			else
			{
				$("#websiteInfoResult").html("<span style='color: red; font-weight:bold; font-style:italic'>Your reference has not been generated.</span>");
			}
		 });
	}

	return false;
}
</script>
<script>
function Del_ComposeAssignmentTemp(tag, id)
{
	if (confirm('Do you want to delete this draft assignment?'))
	{
		$.post("application/action.php", 
			{module : 'delete_assignment_temp', id : id}, 
			function(data){				
				var trCurrent = tag.parentNode.parentNode;
				var tbl = trCurrent.parentNode;									
				$(trCurrent).remove();
				//update order				
				var length = tbl.rows.length - 3;
				for(var i = 1; i < length; i++)
				{
					$(tbl.rows[i].cells[0]).text(i + ".");
				}
			}
		);
	}
}

function Del_Refernce(tag, str)
{
	if(confirm('Are you sure you want to delete this?'))
	{
		if (str=="")
	  	{ 
	  		document.getElementById("DelReference").innerHTML="";
	  		return;
	  	} 
		$.get("view/reference.php?id="+str, function(e){
			if (e == "1")
			{
				var row1 = tag.parentNode.parentNode;
				var tbody = row1.parentNode;
				
				var index = row1.rowIndex;
				tbody.deleteRow(index + 1);
				tbody.deleteRow(index);
			}
		});
	}
	return false;  
}
</script>

<SCRIPT language="javascript">
        function addRow(tableID) {
 
            var table = document.getElementById(tableID);
 
            var rowCount = table.rows.length;
            var row = table.insertRow(rowCount);

            var colCount = table.rows[0].cells.length;

            for(var i=0; i<colCount; i++) {
			
			
			 if(rowCount > 6) {
                        alert("You Can't Add More 8 Than Authors");
                        break;
                    }
                var newcell = row.insertCell(i);
 
                newcell.innerHTML = table.rows[0].cells[i].innerHTML;				              
				$(newcell).find(":text").removeClass("invalid");
                switch(newcell.childNodes[0].type) {
                    case "text":
                            newcell.childNodes[0].value = "";
                            break;
                    case "checkbox":
                            newcell.childNodes[0].checked = true;							
                            break;
                    case "text":
                            newcell.childNodes[0].value = "";
                            break;
                }
            }
			
        }
		
		function clearAndKeepOneRow(tableID) {
			var table = document.getElementById(tableID);
            var rowCount = table.rows.length;
			for(var i= rowCount - 1; i >= 1; i--) {
                table.deleteRow(i);
            }
            //clear content last row
			if (table.rows.length > 0)
			{
				$(table.rows[0]).find(":text").removeClass("invalid").val("");
			}
        }
 
        function deleteRow(tableID) {
			
            try {
			var table = document.getElementById(tableID);
            var rowCount = table.rows.length;
			for(var i=0; i<rowCount; i++) {
                var row = table.rows[i];
                var chkbox = row.cells[0].childNodes[0];
				if(null != chkbox && true == chkbox.checked) {
                    if(rowCount <= 1) {
                        alert("Cannot delete all the rows.");
                        break;
                    }
                    table.deleteRow(i);
					rowCount--;
                    i--;
                }
 
            }
            }catch(e) {
                return false;
            }
        }
 
    </SCRIPT>
<script type="text/javascript" language="javascript">
function show(str)
{
	if(str==4){
		document.getElementById('tdResourceCentre').style.display = 'block';
	}else{
		document.getElementById('tdResourceCentre').style.display = 'block';
	}
	var i=1;
	for(i=1;i<=4;i++)
	{
		if(str==i){
			$("#menu"+str).show(10);
		}else{
			$("#menu"+i).hide(10);
			$("#menu0").hide();
		}
	}
}
function show_txt_title() {
	$('#txt_title').hide();
	$('#txt_title2').show();	
}
function edit_txt_title() {
	//var xurl = true_uri + '/aw/application/edit_title.php';
	var xurl = true_uri + '/application/edit_title.php';
	$.ajax({
		type: 'POST',
		url: xurl,
		data: ({txt_title: $('#text_title').val(), user: '<?php echo $UserID; ?>', title_id: '<?php echo $title_reference_id; ?>'}),
		dataType: 'html',
		cache: false,
		success: function(data) {
			$('#txt_title').html('<b>'+$('#text_title').val()+'</b><a href="#" onclick="show_txt_title();">&nbsp;&nbsp;<img src="./images/edit.jpg" border="0" title="EDIT" alt="EDIT" /></a>');
			$('#txt_title2').hide();
			$('#txt_title').show();
		},
		error: function(xhr) {
			alert('Error! Status = ' + xhr.status);
		}
	});	
}

</script>

<?php
if(isset($_POST['SubmitCompose']))
{
	$dets = $_POST['area1'];
	$sql = mysql_query("insert into composedocument set comments='".$dets."',username='".$UserID."',types='compose'");
	if($sql)
	echo "<script>location.href='index.php?page=assignment_manager&_v=c';</script>";
}


function getDoupleQuoteText($text)
{
	return str_replace("'", "''", $text);
}

if(isset($_POST['SubmitBook']))
{
	$_SESSION['add'] = 1;
	$chkbox = $_POST['chk1'];
	$txtbox = $_POST['txt1'];
	$country = $_POST['country1'];
	$size = sizeof($_POST['country1']);
	$count="";
	$title_rf = $title_reference_id;
	
	for($i=0;$i<=$size;$i++){
	$comm = (($size-2)>=$i)? ", " : ".";
	if($_POST['txt1'][$i]!="")
	$auth .= $_POST['txt1'][$i]."`".$_POST['country1'][$i].$comm;
	}
	if(isset($_SESSION['ReferenceCode']))
	{
		$codes = $_SESSION['ReferenceCode'];
	}
	else
	{
		$_SESSION['ReferenceCode'] = date("Ymdhis");
		$codes = $_SESSION['ReferenceCode'];
	}
	
	if(isset($_GET['_e']))
	{
		$str  = "update composedocument set booktitle='". getDoupleQuoteText($_POST['title1']). "',publisher='". getDoupleQuoteText($_POST['pub1']) . "',";
		$str .= "pcity='". getDoupleQuoteText($_POST['pcity1']) . "',pyear='". getDoupleQuoteText($_POST['date1']) . "',edition='". getDoupleQuoteText($_POST['edition1']) . "',";
		$str .= "pagenumber='" . getDoupleQuoteText($_POST['pages1']) . "',firstname='". getDoupleQuoteText($_POST['firstname1']) ."',lastname='" . getDoupleQuoteText($_POST['lastname1'])."',";
		$str .= "author='". getDoupleQuoteText($auth) . "' where id='". getDoupleQuoteText($_GET['_e'])."'";
	}
	else{
		$str  = "insert into composedocument set booktitle='". getDoupleQuoteText($_POST['title1']) . "',publisher='" . getDoupleQuoteText($_POST['pub1']) . "',";
		$str .= "pcity='" . getDoupleQuoteText($_POST['pcity1'])."',pyear='". getDoupleQuoteText($_POST['date1']) . "',edition='".getDoupleQuoteText($_POST['edition1']) . "',";
		$str .= "pagenumber='" . getDoupleQuoteText($_POST['pages1']) . "',firstname='" . getDoupleQuoteText($_POST['firstname1']) . "',lastname='" . getDoupleQuoteText($_POST['lastname1']) . "',";
		$str .= "author='". getDoupleQuoteText($auth) . "',username='" . getDoupleQuoteText($UserID) . "',types='book',reference='$codes', title_reference='$title_rf'";
	}
	//echo $str;
	$exe = mysql_query($str);
	if($exe)
	echo "<script>location.href='index.php?page=assignment_manager&_v=b&tr=".$title_rf."';</script>";
}

if(isset($_POST['SubmitJournal']))
{
	$_SESSION['add'] = 1;
	$chkbox = $_POST['chk2'];
	$txtbox = $_POST['txt2'];
	$country = $_POST['country2'];
	$size = sizeof($_POST['country2']);
	$count="";
	$title_rf = $title_reference_id;
	
	for($i=0;$i<=$size;$i++){
	$comm = (($size-2)>=$i)? "," : "";
	if($_POST['txt2'][$i]!="")
	$auth .= $_POST['txt2'][$i]."`".$_POST['country2'][$i].$comm;
	}
	if(isset($_GET['_e']))
	{
		$str  = "update composedocument set booktitle='". getDoupleQuoteText($_POST['title2'])."',publisher='" . getDoupleQuoteText($_POST['pub2']) . "',";
		$str .= "journaltitle='" . getDoupleQuoteText($_POST['journal2']) . "',issuenumber='" . getDoupleQuoteText($_POST['issue2']) . "',";
		$str .= "digitalobject='" . getDoupleQuoteText($_POST['digital2']) . "',";
		$str .= "pcity='" . getDoupleQuoteText($_POST['pcity2']) . "',pyear='" . getDoupleQuoteText($_POST['date2']) . "',edition='" . getDoupleQuoteText($_POST['edition2']) . "',";
		$str .= "pagenumber='" . getDoupleQuoteText($_POST['pages2']) . "',firstname='" . getDoupleQuoteText($_POST['firstname2']) . "',lastname='" . getDoupleQuoteText($_POST['lastname2']) ."',";
		$str .= "author='". getDoupleQuoteText($auth) . "' where id='". getDoupleQuoteText($_GET['_e']) . "'";
	}
	else
	{
		$str  = "insert into composedocument set booktitle='" . getDoupleQuoteText($_POST['title2']) . "',publisher='" . getDoupleQuoteText($_POST['pub2']) . "',";
		$str .= "journaltitle='" . getDoupleQuoteText($_POST['journal2']) . "',issuenumber='" . getDoupleQuoteText($_POST['issue2']) . "',";
		$str .= "digitalobject='" . getDoupleQuoteText($_POST['digital2']) ."',";
		$str .= "pcity='" . getDoupleQuoteText($_POST['pcity2'])."',pyear='" . getDoupleQuoteText($_POST['date2']) . "',edition='" . getDoupleQuoteText($_POST['edition2']) . "',";
		$str .= "pagenumber='" . getDoupleQuoteText($_POST['pages2'])."',firstname='" . getDoupleQuoteText($_POST['firstname2']) . "',lastname='".$_POST['lastname2']."',";
		$str .= "author='" . getDoupleQuoteText($auth) . "',username='" . getDoupleQuoteText($UserID) . "',types='journal', title_reference='$title_rf'";	
	}
	$exe = mysql_query($str);
	if($exe)
	echo "<script>location.href='index.php?page=assignment_manager&_v=j';</script>";
}

if(isset($_POST['Submitwebsite']))
{
	$_SESSION['add'] = 1;
	$chkbox = $_POST['chk3'];
	$txtbox = $_POST['txt3'];
	$country = $_POST['country3'];
	$size = sizeof($_POST['country3']);
	$count="";
	
	for($i=0;$i<=$size;$i++){
	$comm = (($size-2)>=$i)? ", " : ".";
	if($_POST['txt3'][$i]!="")
	$auth .= $_POST['txt3'][$i]."`".$_POST['country3'][$i].$comm;
	}
	if(isset($_GET['_e']))
	{
		$str  = "update composedocument set name_of_webpage='". getDoupleQuoteText($_POST['name_of_webpage']) . "',name_of_website='" . getDoupleQuoteText($_POST['name_of_website']) . "',";
		$str .= "website_year='" . getDoupleQuoteText($_POST['website_year']) . "',website_month='" . getDoupleQuoteText($_POST['website_month']) . "',website_day='".$_POST['website_day']."',";
		$str .= "website_year_accessed='" . getDoupleQuoteText($_POST['website_year_accessed']) . "',";
		$str .= "website_month_accessed='" . getDoupleQuoteText($_POST['website_year_accessed']) . "',";
		$str .= "website_day_accessed='" . getDoupleQuoteText($_POST['website_day_accessed'])."',";
		$str .= "website_url='" . getDoupleQuoteText($_POST['website_url']) . "',";	
		$str .= "firstname='" . getDoupleQuoteText($_POST['firstname3']) . "',lastname='" . getDoupleQuoteText($_POST['lastname3']) . "',";
		$str .= "author='" . getDoupleQuoteText($auth) . "' where id='". getDoupleQuoteText($_GET['_e']) . "'";
	}
	else
	{
		$str  = "insert into composedocument set name_of_webpage='" . getDoupleQuoteText($_POST['name_of_webpage']) . "',name_of_website='" . getDoupleQuoteText($_POST['name_of_website']) . "',";
		$str .= "website_year='" . getDoupleQuoteText($_POST['website_year']) . "',website_month='" . getDoupleQuoteText($_POST['website_month']) . "',website_day='" . getDoupleQuoteText($_POST['website_day']) . "',";
		$str .= "website_year_accessed='" . getDoupleQuoteText($_POST['website_year_accessed']) . "',";
		$str .= "website_month_accessed='" . getDoupleQuoteText($_POST['website_month_accessed']) . "',";
		$str .= "website_day_accessed='" . getDoupleQuoteText($_POST['website_day_accessed']) . "',";
		$str .= "website_url='" . getDoupleQuoteText($_POST['website_url']) . "',";		
		$str .= "firstname='" . getDoupleQuoteText($_POST['firstname3']) . "',lastname='" . getDoupleQuoteText($_POST['lastname3']) . "',";
		$str .= "author='". getDoupleQuoteText($auth) . "',username='" . getDoupleQuoteText($UserID) . "',types='web', title_reference='$title_rf'";	
	}
	$exe = mysql_query($str);
	if($exe)
	echo "<script>location.href='index.php?page=assignment_manager&_v=w';</script>";
}

$edit = mysql_fetch_array(mysql_query("select * from composedocument where id='".$_GET['_e']."'"));
if(isset($_POST['Search']))
{
	echo "<script>location.href='index.php?page=assignment_manager&key=".$_POST['keywords']."';</script>";
}
/////////////////// Activate Product Category //////////////////////
if(isset($_REQUEST['AllActive']))
{
	$count=mysql_num_rows(mysql_query("select * from resource_centre"));
	for($i=0;$i<$count;$i++)
	{
		$del_id = $_POST['chk'][$i];
		if($del_id!=""){
		$all=mysql_fetch_array(mysql_query("select * from resource_centre where id='".$del_id."'"));
		$result  = "insert into composedocument set types='journal',journaltitle='".$all['book_title']."',";
		$result .= "publisher='".$all['publisher']."',pcity='".$all['city']."',pyear='".$all['year']."',";
		$result .= "edition='".$all['edition']."',issuenumber='".$all['issuenumber']."',pagenumber='".$all['pagenumber']."',";
		$result .= "firstname='".$all['firstname']."',lastname='".$all['lastname']."',username='".$UserID."',";
		$result .= "booktitle='".$all['concept']."'";
		$exe = mysql_query($result);
		}
	}
	if($exe)
	echo "<script>location.href='index.php?page=assignment_manager';</script>";
}

/////////////////// Selected Articles add to articles //////////////////////
if(isset($_REQUEST['AllArticles']))
{	
/* 	echo "HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello".$_POST['chks'][0]." ";
	$count=mysql_num_rows(mysql_query("select * from composedocument where username='".$UserID."' and types='compose' order by id DESC"));
	$ids = '';
	for($i=0;$i<$count;$i++)
	{
		
		$del_id = $_POST['chks'][$i];
		if($del_id!=""){
			$ids.= $del_id.",";
		}
	}
	if($ids!="")
		header("location:index.php?page=assignment_manager&view=add_assign&_t=comp&ids=".$ids); */
	echo "<script>location.href='index.php?page=assignment_manager&view=add_assign&_t=comp&ids=".$_POST['chks'][0]."';</script>";
}
?>
<script type="text/javascript" language="javascript">
function getbooks(str)
{
	var j;
	var books = $("#booksearch").val();	
	if ($.trim(books) == "")
	{
		alert("Please enter your ISBN, title or author");
		$("#booksearch").focus();
		return;
	}
		
	$("#loading").show();
	if(str==1){
	$("#booksresult").hide();}
		
	var url="ajax/bookinfo.php";
	url=url+"?fname=u";
	url=url+"&val="+books+"&pages="+str;
	
	$.get(url, function(args){
		$("#loading").hide();
			//$("#req"+val).slideUp(1000);
			var gets = args;
			$("#booksresult").show();			
			if(str>1)
			$("#booksmore"+str).html(gets);			
			else
			$("#booksresult").html(gets);
			//document.getElementById("img"+val).innerHTML=httpxml.responseText;	
			//alert(httpxml.responseText);
			if(str>1){
				var objDiv = document.getElementById("booksresult");
				objDiv.scrollTop = objDiv.scrollHeight; 
			}
			reloadReferencesList();
	});
}

function showbooksinfo(title,author,pub,pubdat, publisher_city, edition, isbn)
{	
	var a = author.split(" ");
	Fauthor = "";
	Lauthor = "";
	if (a.length > 0)
	{
		Fauthor = a[0];	
	}
	
	if (a.length > 1)
	{
		Lauthor = a[a.length - 1];
		if (Lauthor.indexOf("(") >= 0 && Lauthor.indexOf(")") > 0)
		{
			if (a.length > 2)
			{
				Lauthor = a[a.length - 2];
			}
		}
	}

	/*
	$("#booksresult").hide();
	$("#first").hide();
	$("#second").show();
	$("#bookinfo").show();
	*/
	$("#title1").val(title);
	$("#firstname1").val(Fauthor);
	$("#lastname1").val(Lauthor);	
	$("#pub1").val(pub);
	$("#pcity1").val(publisher_city);
	var b = pubdat.split("-");
	$("#date1").val(b[0]);
	$('#edition1').val(edition);
	
	saveBookGenerate(isbn, false);		
}
</script>
<input type="hidden" id="title_reference_key" value="<?php echo $title_reference_key; ?>">
<div class="mainWarpArea" style="padding:0; margin:0;">
    <!-- Begin contentwarp -->
    <div class="contentwarp">
      <div id="register" style="background-color:#FFF;float:left;width:980px;border:0px solid #CCC;">
        <!-- Begin ContentBox -->
 
  		<h2 style="padding-left: 20px;" class="classifiedstitle">
        <span style="color:#00619C; font-family:'Palatino Linotype', 'Book Antiqua', Palatino, serif;">Assignment Wizard</span></h2>
 <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td id="tdResourceCentre" width="25%" rowspan="2" align="center" valign="top" class="font12">
    <form action="" method="post" name="forms">
    <table width="95%" style="width:230px;" border="0" align="center" cellpadding="0" cellspacing="0">
      <!--<tr>
        <td height="30" colspan="2" align="center" valign="middle" id="radientbox" class="font12">RESOURCE CENTRE</td>
      </tr>
      <tr>
        <td height="10" colspan="3" align="center" valign="middle" class="font12"></td>
      </tr>  
      <tr>
        <td align="center" valign="middle">
        <input type="text" name="keywords" id="keywords" style="width:185px;" value="<?php echo $_GET['key']?>" class="txtborder" /></td>
        <td align="center" valign="middle">
        <input type="submit" name="Search" value="" class="searchbutton" /></td>
        </tr>
      <tr>
        <td colspan="2" align="center" valign="middle">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="borders" style="border-top:none;">
          <tr>
            <td width="12%">&nbsp;</td>
            <td width="88%" class="font12">&nbsp;</td>
          </tr>
		  <?php
		  if(isset($_GET['key'])){
		  $list = mysql_query("select * from resource_centre where concept like '%".$_GET['key']."%'");
		  while($key = mysql_fetch_array($list)){
          ?>
          <tr>
            <td width="12%"><input type="checkbox" name="chk[]" id="chk" value="<?php echo $key['id']?>"/></td>
            <td width="88%" class="font12"><b>
			<A href="<?php echo $key['url']?>" target="_blank" class="font12"><?php echo $key['concept']?></A></b></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td class="font12" style="font-size:10px; color:#666;">
            <?php echo $key['firstname']." ".$key['lastname'];?>. (<?php echo $key['year'];?>). <?php echo $key['book_title'];?>, <?php echo $key['edition'];?>(<?php echo $key['issuenumber'];?>), <?php echo $key['pagenumber'];?>, <?php echo $key['city'];?>.</td>
          </tr>
          <tr>
            <td height="5" colspan="2"></td>
          </tr>
          <?php }}?>
          <tr>
            <td>&nbsp;</td>
            <td class="font12" style="font-size:10px; color:#666;">&nbsp;</td>
          </tr>
          <?php if(isset($_GET['key'])){
			  $tot = mysql_num_rows($list);
			  if($tot>0){
			  ?>
          <tr>
            <td colspan="2"><input type="submit" name="AllActive" class="buttonbg" style="width:120px;" value="ADD REFERENCE" title="ADD REFERENCE" /></td>
            </tr>
            <?php } else{/*echo "<span class='red'>- No REFERENCE Found -</span>";*/}}?>
        </table>
        </td>
      </tr>
      <tr>
        <td colspan="2" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2" align="left" valign="middle">&nbsp;</td>
      </tr>-->
      <!-- list of on doing assignment -->
	  <?php if(isset($_SESSION['user_id'])) { ?> 
	  <tr>
        <td height="30" colspan="2" align="center" valign="middle" id="radientbox" class="font12">LIST OF ASSIGNMENTS</td>
      </tr>
      <tr>
        <td colspan="2" align="left" valign="middle">
			<div style="height: 300px;background-color: white;overflow: auto;border-top: none">
				<table width="100%" cellpadding="0" cellspacing="0" border="0">
					<tr>
						<td height="10" colspan="3"></td>
					  </tr>
					<?php
						$list_doing_assignment = mysql_query("SELECT * FROM composedocument WHERE username='".$_SESSION['user_id']."' and types='compose' ORDER BY id DESC");
						$i = 1;
						while($list_d_a = @mysql_fetch_array($list_doing_assignment)) {
							echo "<tr>";
							echo "<td width='10px' align=\"center\" style=\"padding: 3px;\">$i.</td>";
							echo "<td style=\"padding: 3px;\">". ($list_d_a['assignmenttitle'] == "" ? "No title" : $list_d_a['assignmenttitle'])."</td>";
							echo "<td align=\"right\" style=\"padding-right: 10px;\"><a href=\"?index.php&page=assignment_manager&view=continue_assign&id=".$list_d_a['id']."&tr=".
							$list_d_a['title_reference']."\"><img src=\"./images/edit.jpg\" border=\"0\" title=\"EDIT\" alt=\"EDIT\" /></a><a href='javascript:void(0)' style='margin-left:8px;' onclick='Del_ComposeAssignmentTemp(this,\"" . 
							$list_d_a['id'] . "\")'><img src='./images/delete.jpg' border=\"0\" title=\"Delete\" alt=\"Delete\" /></a>" .
							"<a style='margin-left:8px;' href=\"javascript:void(0)\" onclick=\"sendEmailToMe('" . $list_d_a['id'] . "','" . $list_d_a['title_reference'] . "')\"><img height=\"16px\" src=\"./images/email.png\" border=\"0\" title='Send to my email' /></a>" .
							"</td>";
							echo "</tr>";
						$i++;
						}
					?>
					<tr>
						<td height="5" colspan="3"></td>
					  </tr>
					  <tr>
						<td height="1" bgcolor="#E4E4E4" colspan="3"></td>
					  </tr>
					  <tr>
						<td height="5" colspan="3"></td>
					  </tr>
				</table>
			</div>
		</td>
      </tr>
	  <?php } ?>
	  <!-- end list of on doing assignment -->
	  <tr>
        <td colspan="2" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2" align="left" valign="middle">&nbsp;</td>
      </tr>
      <?php /*?><tr>
        <td colspan="2" align="center" valign="middle" class="font12">ASSIGNMENT</td>
        </tr>
      <tr>
        <td height="1" colspan="3" align="center" valign="middle" bgcolor="#E4E4E4" class="font12"></td>
      </tr>
      <tr>
        <td colspan="2" align="center" valign="middle" class="font12">&nbsp;</td>
      </tr><?php */?>
      <!--<tr>
        <td height="20" colspan="2" align="center" valign="middle" class="font12">
        <div style="height:300px; overflow:auto; display:block;">
        <table width="100%" style="width:200px;" border="0" cellspacing="0" cellpadding="0" class="borders">
          <?php
		  $listaa = mysql_query("select * from composedocument where username='".$UserID."' and types='compose' order by id DESC");
		  while($keya = mysql_fetch_array($listaa)){
          ?>
          <tr>
            <td width="12%" align="center" valign="top">
            <input type="checkbox" name="chks[]" id="chks" value="<?php echo $keya['id']?>"/></td>
            <td width="88%" align="left" valign="middle" class="font12">
			<?php $tt = $keya['comments'];
			$dd=strip_tags($tt,'');
			echo substr($dd,0,100)."...";
			?><a href="javascript:void(0)" onclick="delete_assignment('<?php echo $keya['id']; ?>',this)">&nbsp;&nbsp;Delete<a></td>
          </tr>          
          <tr>
            <td height="1" colspan="2" style="padding:5px;">
            	<div style="border-bottom:solid 1px #E4E4E4;height:1px;"></div>
            </td>
          </tr>          
          <?php }?>
          <tr>
            <td>&nbsp;</td>
            <td class="font12" style="font-size:10px; color:#666;">&nbsp;</td>
          </tr>
          <?php 
			  $totA = mysql_num_rows($listaa);
			  if($totA>0){
			  ?>
          <tr>
            <td colspan="2">
            
            </td>
            </tr>
            <?php }else{echo "<span class='red'>- No ASSIGNMENT Found -</span>";}?>
            
        </table>
        </div>
        </td>
      </tr>-->
      <tr>
        <td height="20" colspan="2" align="center" valign="middle" class="font12">&nbsp;</td>
      </tr>
      </table>
      </form>
      </td>
    <td width="45%" align="center" valign="top">
    <?php
      $gnr = (isset($_GET['_t']))? "none" : "block";
	  ?>
    <div id="menu0" style="display:<?php echo $gnr;?>;"> 
    <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td height="25" align="center" valign="middle" bgcolor="#F0F0F0" class="font12" onclick="show('1');" style="cursor:pointer;">
        <img src="./images/book.png" border="0" /></td>
        <td align="center" valign="middle" bgcolor="#F0F0F0" class="font12"  onclick="show('2');" style="cursor:pointer;">
        <img src="./images/journal.png" border="0" /></td>
        <td align="center" valign="middle" bgcolor="#F0F0F0" class="font12"  onclick="show('3');" style="cursor:pointer;">
        <img src="./images/website.png" border="0" /></td>
        <td align="center" valign="middle" bgcolor="#F0F0F0" class="font12"  style="cursor:pointer;">
        <?php if(isset($_SESSION['user_id'])){?>
        <a href="index.php?page=assignment_manager&view=add_assign"><img src="./images/compose.png" border="0" /></a>
        <?php }else{?>
        <a href="#" id="buttonpopup2" class="hyberlik1"><img src="./images/compose.png" border="0" /></a>
        <?php }?>
		</td>
      </tr>
      <tr>
        <td width="21%" height="25" align="center" valign="middle" bgcolor="#F0F0F0" class="font12">Book</td>
        <td width="27%" align="center" valign="middle" bgcolor="#F0F0F0" class="font12">Journal article</td>
        <td width="24%" align="center" valign="middle" bgcolor="#F0F0F0" class="font12">Website </td>
        <td width="28%" align="center" valign="middle" bgcolor="#F0F0F0" class="font12">Compose assignment</td>
        </tr>
        <tr>
        <td height="10" colspan="4" align="left" valign="middle"></td>
        </tr>
      <tr>
        <td height="30" colspan="4" align="left" valign="middle" class="font12">
        	<?php
		  		$listaa = mysql_query("select * from section where id='7'");
		  		$keya = mysql_fetch_array($listaa);
		  		echo $keya['content'];
          ?>        
        </td>
        </tr>      
      <tr>
        <td colspan="4" align="left" valign="middle">&nbsp;</td>
      </tr>
      </table>
      </div>
      <?php
      $books = ($_GET['_t']=="book")? "block" : "none";
	  ?>
    <div id="menu1" style="display:<?php echo $books;?>;"> 
    <form action="" method="post" name="form1" id="form1" onsubmit="return validate1(this);">
    <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="borders" style="border:1px solid #8B98C9;">
      <tr>
        <td height="25" align="center" valign="middle" bgcolor="#F0F0F0" class="font12" onclick="show('1');" style="cursor:pointer;">
        <img src="./images/book.png" border="0" /></td>
        <td align="center" valign="middle" bgcolor="#F0F0F0" class="font12"  onclick="show('2');" style="cursor:pointer;">
        <img src="./images/journal.png" border="0" /></td>
        <td align="center" valign="middle" bgcolor="#F0F0F0" class="font12"  onclick="show('3');" style="cursor:pointer;">
        <img src="./images/website.png" border="0" /></td>
        <td align="center" valign="middle" bgcolor="#F0F0F0" class="font12" style="cursor:pointer;">
		<?php if(isset($_SESSION['user_id'])){?>
        <a href="index.php?page=assignment_manager&view=add_assign"><img src="./images/compose.png" border="0" /></a>
        <?php }else{?>
        <a href="#" id="buttonpopup3" class="hyberlik1"><img src="./images/compose.png" border="0" /></a>
        <?php }?></td>
      </tr>
      <tr>
        <td width="21%" height="25" align="center" valign="middle" bgcolor="#F0F0F0" class="font12" style="color:#2964BA;"><strong>Book</strong></td>
        <td width="27%" align="center" valign="middle" bgcolor="#F0F0F0" class="font12">Journal article</td>
        <td width="24%" align="center" valign="middle" bgcolor="#F0F0F0" class="font12">Website </td>
        <td width="28%" align="center" valign="middle" bgcolor="#F0F0F0" class="font12">Compose assignment</td>
        </tr>
      <tr>
        <td colspan="4" align="left" valign="middle">
        <div id="second" style="display:none;">
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td align="center" valign="middle" class="font12" style="color:#2964BA;">&nbsp;</td>
          </tr>
          <tr>
            <td align="center" valign="middle" class="font12" style="color:#2964BA;">
             <b>Auto-generate</b> | <a href="javascript:void(0)" onclick="generateBookManually()" class="book-function-type">Generate manually</a>
            </td>
          </tr>
          <tr>
            <td align="center" valign="middle">&nbsp;</td>
          </tr>
          <tr>
            <td align="left" valign="middle">
            <input name="booksearch" id="booksearch" type="text" style="width:230px;" class="txtborder" onkeypress="return booksearchKeyPress(event)" />
              <input name="SearchAuto" type="button" onclick="getbooks('1');" value="Search" class="buttonbg" id="btnFindBook" style="width:150px";/></td>
          </tr>
          <tr>
            <td align="center" valign="middle">&nbsp;</td>
          </tr>
        </table>
        </div>
        <div id="first" style="display:block;">
	        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
	          <tr>
	            <td align="center" valign="middle" class="font12" style="color:#2964BA;">&nbsp;</td>
	          </tr>
	          <tr>
	            <td align="center" valign="middle" class="font12" style="color:#2964BA;">
	            	<a href="javascript:void(0);" onclick="generateBookAuto()" class="book-function-type">Auto-generate</a> | <b>Generate manually</b>
	            </td>
	          </tr>
	          <tr>
	            <td align="center" valign="middle">&nbsp;</td>
	          </tr>
	        </table>
        </div>
        
        </td>
      </tr>
      <tr>
        <td colspan="4" align="center" valign="middle">
        <div id="booksresult" style="height:500px; overflow:auto; width:400px; display:none;text-align:left;color:black;"></div>
        <div id="loading" style="display:none;">
      <img src="images/ajax-loader.gif" border="0" /></div>
        </td>
      </tr>
      <tr>
        <td colspan="4" align="center" valign="middle">
        <div class="error-notice" id="book_error_notice" style="display:none">Highlighted fields are recommended, fill them!
        </div>
        <div id="bookinfo" style="display:block;">
		<div id="bookinfoResult"></div>
        <table width="95%" border="0" align="center" cellpadding="0" cellspacing="2">
          <tr>
            <td height="30" colspan="4" align="left" valign="middle" class="font12" style="color:#2964BA;"><b>Book Info</b></td>
            </tr>
          <tr>
            <td colspan="4" align="left" valign="middle">
            <table width="100%" border="0" align="center" cellpadding="0" cellspacing="2">
              <tr>
                <td width="41%" height="25" align="right" valign="middle" class="font12">Title of the Book</td>
                <td width="7%" align="center" valign="middle" class="red">*</td>
                <td width="52%" align="left" valign="middle">
                <input type="text" name="title1" id="title1" class="txtborder" value="<?php echo $edit['booktitle']?>" />
                </td>
              </tr>
              <tr>
                <td height="25" align="right" valign="middle" class="font12">Publisher</td>
                <td align="center" valign="middle" class="red">*</td>
                <td align="left" valign="middle">
                <input type="text" name="pub1" id="pub1" class="txtborder" value="<?php echo $edit['publisher']?>" /></td>
              </tr>
              <tr>
                <td height="25" align="right" valign="middle" class="font12">Publisher's City</td>
                <td align="center" valign="middle" class="red">*</td>
                <td align="left" valign="middle">
                <input type="text" name="pcity1" id="pcity1" class="txtborder" value="<?php echo $edit['pcity']?>" /></td>
              </tr>
              <tr>
                <td height="25" align="right" valign="middle" class="font12">Year Published</td>
                <td align="center" valign="middle" class="red">*</td>
                <td align="left" valign="middle">
                <input type="text" name="date1" id="date1" class="txtborder" value="<?php echo $edit['pyear']?>" /></td>
              </tr>
              <tr>
                <td height="25" align="right" valign="middle" class="font12">Edition</td>
                <td align="center" valign="middle">&nbsp;</td>
                <td align="left" valign="middle">
                <select name="edition1" class="txtborder" style="width:143px;" id="edition1">
				  <option value=""></option>
                  <option <?php if($edit['edition']=="1st ed."){echo "selected";}?> value="1st ed.">1st Edition</option>
                  <option <?php if($edit['edition']=="2nd ed."){echo "selected";}?> value="2nd ed.">2nd Edition</option>
                  <option <?php if($edit['edition']=="3rd ed."){echo "selected";}?> value="3rd ed.">3rd Edition</option>
                  <option <?php if($edit['edition']=="4th ed."){echo "selected";}?> value="4th ed.">4th Edition</option>
                  <option <?php if($edit['edition']=="5th ed."){echo "selected";}?> value="5th ed.">5th Edition</option>
                  <option <?php if($edit['edition']=="6th ed."){echo "selected";}?> value="6th ed.">6th Edition</option>
                  <option <?php if($edit['edition']=="7th ed."){echo "selected";}?> value="7th ed.">7th Edition</option>
                  <option <?php if($edit['edition']=="8th ed."){echo "selected";}?> value="8th ed.">8th Edition</option>
                  <option <?php if($edit['edition']=="9th ed."){echo "selected";}?> value="9th ed.">9th Edition</option>
                  <option <?php if($edit['edition']=="10th ed."){echo "selected";}?> value="10th ed.">10th Edition</option>
                  <option <?php if($edit['edition']=="11th ed."){echo "selected";}?> value="11th ed.">11th Edition</option>
                  <option <?php if($edit['edition']=="12th ed."){echo "selected";}?> value="12th ed.">12th Edition</option>
                  <option <?php if($edit['edition']=="13th ed."){echo "selected";}?> value="13th ed.">13th Edition</option>
                  <option <?php if($edit['edition']=="14th ed."){echo "selected";}?> value="14th ed.">14th Edition</option>
                  <option <?php if($edit['edition']=="15th ed."){echo "selected";}?> value="15th ed.">15th Edition</option>
                  <option <?php if($edit['edition']=="16th ed."){echo "selected";}?> value="16th ed.">16th Edition</option>
                  <option <?php if($edit['edition']=="17th ed."){echo "selected";}?> value="17th ed.">17th Edition</option>
                  <option <?php if($edit['edition']=="18th ed."){echo "selected";}?> value="18th ed.">18th Edition</option>
                  <option <?php if($edit['edition']=="19th ed."){echo "selected";}?> value="19th ed.">19th Edition</option>
                  <option <?php if($edit['edition']=="20th ed."){echo "selected";}?> value="20th ed.">20th Edition</option>
                </select></td>
              </tr>
			  <!--
              <tr>
                <td height="25" align="right" valign="middle" class="font12">Page numbers</td>
                <td align="center" valign="middle" class="red">*</td>
                <td align="left" valign="middle">
                <input type="text" name="pages1" id="pages1" class="txtborder" value="<?php echo $edit['pagenumber']?>" /></td>
              </tr>-->
            </table></td>
          </tr>
          <tr>
            <td colspan="4" align="left" valign="middle">&nbsp;</td>
          </tr>
          <tr>
            <td height="1" colspan="4" align="left" valign="middle" bgcolor="#8B98C9"></td>
            </tr>
            <tr>
            <td colspan="4" align="left" height="10" valign="middle"></td>
          </tr>
          <tr>
            <td colspan="4" align="left" valign="middle" class="font12" style="color:#2964BA;"><b>Author Name(s)</b></td>
          </tr>
          <tr>
            <td colspan="4" align="left" valign="middle">&nbsp;</td>
          </tr>
          <tr>
            <td colspan="4" align="left" valign="middle">
            <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td width="8%" height="25" align="center" valign="middle" class="font12">&nbsp;</td>
                <td width="43%" align="left" valign="middle" class="font12">First Name <span style="color:red">*</span></td>
                <td colspan="2" align="left" valign="middle" class="font12">Last Name <span style="color:red">*</span></td>
                </tr>
              <tr>
                <td align="center" valign="middle">&nbsp;</td>
                <td align="left" valign="middle">
                <INPUT type="text" id="firstname1" name="firstname1" class="txtborder" value="<?php echo $edit['firstname']?>" /></td>
                <td height="25" colspan="2" align="left" valign="middle">
                  <INPUT type="text" name="lastname1" id="lastname1" class="txtborder" value="<?php echo $edit['lastname']?>" /></td>
                </tr>
              <tr>
                <td colspan="4" align="center" valign="middle">
                <TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" id="dataTable1">
                    <?php 
                    $aut = explode(",",$edit['author']);
                    $bcout = count($aut);
                    for($i=0;$i<$bcout;$i++){
                        $names = explode("`",$aut[$i]);
                    ?>
                    <tr>
                        <td width="25"><INPUT type="checkbox" name="chk1[]"/></td>
                        <td width="166" >
                        <INPUT type="text" name="txt1[]" class="txtborder" value="<?php echo $names[0];?>" /></td>
                        <td width="194" align="left">
                        <INPUT type="text"  name="country1[]" class="txtborder" value="<?php echo $names[1];?>" /></td>
                    </tr>
                    <?php }?>
                </TABLE>
                </td>
                </tr>
              <tr>
                <td align="center" valign="middle">
                <INPUT type="button"  style="color:#FFF; background-color:#2964BA; border:#FFF solid 1px; width:20px;" value="-" onclick="deleteRow('dataTable1')" />
                </td>
                <td colspan="3" align="center" valign="middle" class="font12" style="font-size:10px; color:#999;">
                  <span style="float:left;">selected will be remove</span>
                  <INPUT type="button" style="color:#FFF; background-color:#2964BA; border:#FFF solid 1px; width:20px; " value="+" onclick="addRow('dataTable1')" />
                </td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td colspan="4" align="left" valign="middle">&nbsp;</td>
          </tr>
          <tr>
            <td height="1" colspan="4" align="left" valign="middle" bgcolor="#8B98C9"></td>
            </tr>
            <tr>
            <td colspan="4" align="left" height="10" valign="middle"></td>
          </tr>
          <tr>
            <td colspan="4" align="center" valign="middle">
            <input type="submit" name="SubmitBook" class="buttonbg" style="width:180px;" value="Generate References" /></td>
          </tr>
          </table>
      </div>
        </td>
      </tr>
      </table>
      </form>
      </div>
      <?php
	  $jour = ($_GET['_t']=="journal")? "block" : "none";
	  ?>
      <div id="menu2" style="display:<?php echo $jour?>;">
      <form action="" method="post" name="form2" id="form2" onsubmit="return validate2();">
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="borders" style="border:1px solid #4DB332;">
      <tr>
        <td height="25" align="center" valign="middle" bgcolor="#F0F0F0" class="font12" onclick="show('1');" style="cursor:pointer;">
        <img src="./images/book.png" border="0" /></td>
        <td align="center" valign="middle" bgcolor="#F0F0F0" class="font12" onclick="show('2');" style="cursor:pointer;">
        <img src="./images/journal.png" border="0" /></td>
        <td align="center" valign="middle" bgcolor="#F0F0F0" class="font12" onclick="show('3');" style="cursor:pointer;">
        <img src="./images/website.png" border="0" /></td>
        <td align="center" valign="middle" bgcolor="#F0F0F0" class="font12" style="cursor:pointer;">
        <?php if(isset($_SESSION['user_id'])){?>
        <a href="index.php?page=assignment_manager&view=add_assign"><img src="./images/compose.png" border="0" /></a>
        <?php }else{?>
        <a href="#" id="buttonpopup4" class="hyberlik1"><img src="./images/compose.png" border="0" /></a>
        <?php }?></td>
      </tr>
      <tr>
        <td width="21%" height="25" align="center" valign="middle" bgcolor="#F0F0F0" class="font12">Book</td>
        <td width="27%" align="center" valign="middle" bgcolor="#F0F0F0" class="font12" style="color:#4DB332;"><strong>Journal article</strong></td>
        <td width="24%" align="center" valign="middle" bgcolor="#F0F0F0" class="font12">Website</td>
        <td width="28%" align="center" valign="middle" bgcolor="#F0F0F0" class="font12">Compose assignment</td>
        </tr>
		<tr>
		<td colspan="4">
		</td>
	 </tr>
		<tr>
		<td colspan="4">
			<div class="error-notice" id="journal_error_notice" style="display:none;margin-top:10px">Highlighted fields are recommended, fill them!
			</div>
			<div id="journalInfoResult" style="margin-top:10px"></div>
		</td>
	 </tr>
	 <tr>
        <td height="15" colspan="4"></td>
	</td>
	 <tr>
        <td height="30" colspan="4" valign="middle" class="font12" style="color:#4DB332;">
			<b>Search for article</b>
			<input type="text" id="titleArticleSearch" style="margin-left:32px;"/>&nbsp;<input type="button" value="Search" onclick="searchJournal()"/>
		</td>
        </tr>
      <tr>	  
        <td height="30" colspan="4" align="left" valign="middle" class="font12" style="color:#4DB332;"><b>Journal Article Info</b></td>
      </tr>		
      <tr>
        <td colspan="4" align="left" valign="middle"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="45%" height="25" align="right" valign="middle" class="font12">Title of the Article</td>
            <td width="7%" align="center" valign="middle" class="red">*</td>
            <td width="48%" align="left" valign="middle">
            <input type="text" name="title2" id="title2" class="txtborder" value="<?php echo $edit['booktitle']?>" />
            </td>
          </tr>
          <tr>
            <td height="25" align="right" valign="middle" class="font12">Title of the journal</td>
            <td align="center" valign="middle" class="red">*</td>
            <td align="left" valign="middle">
            <input type="text" name="journal2" id="journal2" class="txtborder" value="<?php echo $edit['journaltitle']?>" />
            </td>
          </tr>
          <tr>
            <td height="25" align="right" valign="middle" class="font12">Volume number</td>
            <td align="center" valign="middle" class="red">&nbsp;</td>
            <td align="left" valign="middle">
            <input type="text" name="edition2" id="edition2" class="txtborder" value="<?php echo $edit['edition']?>" />
            </td>
          </tr>
          <tr>
            <td height="25" align="right" valign="middle" class="font12">Issue number</td>
            <td align="center" valign="middle" class="red">&nbsp;</td>
            <td align="left" valign="middle">
            <input type="text" name="issue2" id="issue2" class="txtborder" value="<?php echo $edit['issuenumber']?>" />
            </td>
          </tr>
          <tr>
            <td height="25" align="right" valign="middle" class="font12">Year Published</td>
            <td align="center" valign="middle" class="red">*</td>
            <td align="left" valign="middle">
              <input type="text" name="date2" id="date2" class="txtborder" value="<?php echo $edit['pyear']?>" /></td>
          </tr>
          <tr>
            <td height="25" align="right" valign="middle" class="font12">Page numbers</td>
            <td align="center" valign="middle" class="red">*</td>
            <td align="left" valign="middle">
              <input type="text" name="pages2" id="pages2" class="txtborder" value="<?php echo $edit['pagenumber']?>" /></td>
          </tr>
          <tr>
            <td height="25" align="right" valign="middle" class="font12">Digital Object Identifier(s)</td>
            <td align="center" valign="middle" class="red">&nbsp;</td>
            <td align="left" valign="middle">
            <input type="text" name="digital2" id="digital2" class="txtborder" value="<?php echo $edit['digitalobject']?>" />
            </td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td colspan="4" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td height="1" colspan="4" align="left" valign="middle" bgcolor="#4DB332"></td>

        </tr>
        <tr>
        <td colspan="4" align="left" height="10" valign="middle"></td>
      </tr>
      <tr>
        <td colspan="4" align="left" valign="middle" class="font12" style="color:#4DB332;"><b>Author Name(s)</b></td>
      </tr>
      <tr>
        <td colspan="4" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="4" align="left" valign="middle">
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="8%" height="25" align="center" valign="middle" class="font12">&nbsp;</td>
            <td width="43%" align="left" valign="middle" class="font12">First Name <span style="color:red">*</span></td>
            <td colspan="2" align="left" valign="middle" class="font12">Last Name <span style="color:red">*</span></td>
            </tr>
          <tr>
            <td align="center" valign="middle">&nbsp;</td>
            <td align="left" valign="middle">
            <INPUT type="text" id="firstname2" name="firstname2" class="txtborder" value="<?php echo $edit['firstname']?>" ></td>
            <td height="25" colspan="2" align="left" valign="middle">
              <INPUT type="text" id="lastname2" name="lastname2" class="txtborder" value="<?php echo $edit['lastname']?>"></td>
            </tr>
          <tr>
            <td colspan="4" align="center" valign="middle">
            <TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" id="dataTable2">
                <?php 
				$aut2 = explode(",",$edit['author']);
				$bcout2 = count($aut2);
				for($i=0;$i<$bcout2;$i++){
					$names2 = explode("`",$aut2[$i]);
				?>
                <tr>
                    <td width="25"><INPUT type="checkbox" name="chk2[]"/></td>
                    <td width="166" ><INPUT type="text" name="txt2[]" class="txtborder" value="<?php echo $names2[0]?>" />
                    </td>
                    <td width="194" align="left">
                      <INPUT type="text"  name="country2[]" class="txtborder" value="<?php echo $names2[1]?>" /> 
                    </td>
                 </tr>
                 <?php }?>
            </TABLE>
            </td>
            </tr>
          <tr>
            <td align="center" valign="middle">
            <INPUT type="button"  style="color:#FFF; background-color:#4DB332; border:#FFF solid 1px; width:20px;" value="-" onclick="deleteRow('dataTable2')" />
            </td>
            <td colspan="3" align="center" valign="middle" class="font12" style="font-size:10px; color:#999;">
              <span style="float:left;">selected will be remove</span>
              <INPUT type="button" style="color:#FFF; background-color:#4DB332; border:#FFF solid 1px; width:20px; " value="+" onclick="addRow('dataTable2')" />
            </td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td colspan="4" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td height="1" colspan="4" align="left" valign="middle" bgcolor="#4DB332"></td>
        </tr>
        <tr>
        <td colspan="4" align="left" height="10" valign="middle"></td>
      </tr>
      <tr>
        <td colspan="4" align="center" valign="middle">
        <input type="submit" name="SubmitJournal" class="buttonbg" style="width:180px;" value="Generate References" /></td>
      </tr>
      </table>
      </form>
      </div>
      <?php
      $web = ($_GET['_t']=="web")? "block" : "none";
	  ?>
      <div id="menu3" style="display:<?php echo $web;?>;">
      <form action="" method="post" name="form3" id="form3" onsubmit="return validate3();">
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="borders" style="border:1px solid #CB4B41;">
      <tr>
        <td height="25" align="center" valign="middle" bgcolor="#F0F0F0" class="font12" onclick="show('1');" style="cursor:pointer;">
        <img src="./images/book.png" border="0" /></td>
        <td align="center" valign="middle" bgcolor="#F0F0F0" class="font12" onclick="show('2');" style="cursor:pointer;">
        <img src="./images/journal.png" border="0" /></td>
        <td align="center" valign="middle" bgcolor="#F0F0F0" class="font12" onclick="show('3');" style="cursor:pointer;">
        <img src="./images/website.png" border="0" /></td>
        <td align="center" valign="middle" bgcolor="#F0F0F0" class="font12" style="cursor:pointer;">
        <?php if(isset($_SESSION['user_id'])){?>
        <a href="index.php?page=assignment_manager&view=add_assign"><img src="./images/compose.png" border="0" /></a>
        <?php }else{?>
        <a href="#" id="buttonpopup5" class="hyberlik1"><img src="./images/compose.png" border="0" /></a>
        <?php }?></td>
      </tr>
      <tr>
        <td width="21%" height="25" align="center" valign="middle" bgcolor="#F0F0F0" class="font12">Book</td>
        <td width="27%" align="center" valign="middle" bgcolor="#F0F0F0" class="font12">Journal article</td>
        <td width="24%" align="center" valign="middle" bgcolor="#F0F0F0" class="font12" style="color:#CB4B41;"><strong>Website</strong></td>
        <td width="28%" align="center" valign="middle" bgcolor="#F0F0F0" class="font12">Compose assignment</td>
        </tr>	 
		</tr>
		<tr>
		<td colspan="4">
		</td>
	 </tr>
	 <tr>
		<td colspan="4">
			<div class="error-notice" id="website_error_notice" style="display:none">Highlighted fields are recommended, fill them!			
        </div>
		<div id="websiteInfoResult"></div>
		</td>
	 </tr>
      <tr>
        <td height="30" colspan="4" align="left" valign="middle" class="font12" style="color:#CB4B41;"><b>Website Info</b></td>
        </tr>
		
      <tr>
        <td colspan="4" align="left" valign="middle"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="2">          
          <tr>
            <td height="25" align="right" valign="middle" class="font12">Name of Web Page</td>
            <td align="center" valign="middle" class="red">*</td>
            <td align="left" valign="middle">
            <input type="text" name="name_of_webpage" id="name_of_webpage" class="txtborder" value="<?php echo $edit['name_of_webpage']?>" /></td>
          </tr>
          <tr>
            <td height="25" align="right" valign="middle" class="font12">Name of Web Site</td>
            <td align="center" valign="middle" class="red">*</td>
            <td align="left" valign="middle">
            <input type="text" name="name_of_website" id="name_of_website" class="txtborder" value="<?php echo $edit['name_of_website']?>" /></td>
          </tr>
          <tr>
            <td height="25" align="right" valign="middle" class="font12">Year</td>
            <td align="center" valign="middle" class="red">*</td>
            <td align="left" valign="middle">
            <input type="text" name="website_year" id="website_year" class="txtborder" value="<?php echo $edit['website_year']?>" /></td>
          </tr>
		  <tr>
            <td height="25" align="right" valign="middle" class="font12">Month</td>
            <td align="center" valign="middle" class="red">*</td>
            <td align="left" valign="middle">
            <input type="text" name="website_month" id="website_month" class="txtborder" value="<?php echo $edit['website_month']?>" /></td>
          </tr>
          <tr>
            <td height="25" align="right" valign="middle" class="font12">Day</td>
            <td align="center" valign="middle" class="red">*</td>
            <td align="left" valign="middle">
            <input type="text" name="website_day" id="website_day" class="txtborder" value="<?php echo $edit['website_day']?>" /></td>
          </tr>
		  <tr>
            <td height="25" align="right" valign="middle" class="font12">Year Accessed</td>
            <td align="center" valign="middle" class="red">*</td>
            <td align="left" valign="middle">
            <input type="text" name="website_year_accessed" id="website_year_accessed" class="txtborder" value="<?php echo $edit['website_year_accessed']?>" /></td>
          </tr>
		  <tr>
            <td height="25" align="right" valign="middle" class="font12">Month Accessed</td>
            <td align="center" valign="middle" class="red">*</td>
            <td align="left" valign="middle">
            <input type="text" name="website_month_accessed" id="website_month_accessed" class="txtborder" value="<?php echo $edit['website_month_accessed']?>" /></td>
          </tr>
		  <tr>
            <td height="25" align="right" valign="middle" class="font12">Day Accessed</td>
            <td align="center" valign="middle" class="red">*</td>
            <td align="left" valign="middle">
            <input type="text" name="website_day_accessed" id="website_day_accessed" class="txtborder" value="<?php echo $edit['website_day_accessed']?>" /></td>
          </tr>
		  <tr>
            <td height="25" align="right" valign="middle" class="font12">URL</td>
            <td align="center" valign="middle" class="red">*</td>
            <td align="left" valign="middle">
            <input type="text" name="website_url" id="website_url" class="txtborder" value="<?php echo $edit['website_url']?>" /></td>
          </tr>          
        </table></td>
      </tr>
      <tr>
        <td colspan="4" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td height="1" colspan="4" align="left" valign="middle" bgcolor="#CB4B41"></td>

        </tr>
        <tr>
        <td colspan="4" align="left" height="10" valign="middle"></td>
      </tr>
      <tr>
        <td colspan="4" align="left" valign="middle" class="font12" style="color:#CB4B41;"><b>Author Name(s)</b></td>
      </tr>
      <tr>
        <td colspan="4" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="4" align="left" valign="middle">
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="8%" height="25" align="center" valign="middle" class="font12">&nbsp;</td>
            <td width="43%" align="left" valign="middle" class="font12">First Name <span style="color:red">*</span></td>
            <td colspan="2" align="left" valign="middle" class="font12">Last Name <span style="color:red">*</span></td>
            </tr>
          <tr>
            <td align="center" valign="middle">&nbsp;</td>
            <td align="left" valign="middle">
            <INPUT type="text" id="firstname3" name="firstname3" class="txtborder" value="<?php echo $edit['firstname']?>"></td>
            <td height="25" colspan="2" align="left" valign="middle">
              <INPUT type="text" id="lastname3" name="lastname3" class="txtborder" value="<?php echo $edit['lastname']?>"></td>
            </tr>
          <tr>
            <td colspan="4" align="center" valign="middle">
            <TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" id="dataTable3">
                <?php 
				$aut3 = explode(",",$edit['author']);
				$bcout3 = count($aut3);
				for($i=0;$i<$bcout3;$i++){
					$names3 = explode("`",$aut3[$i]);
				?>
                <tr>
                    <td width="25"><INPUT type="checkbox" name="chk3[]"/></td>
                    <td width="166" ><INPUT type="text" name="txt3[]" class="txtborder" value="<?php echo $names3[0];?>" /></td>
                    <td width="194" align="left">
                      <INPUT type="text"  name="country3[]" class="txtborder" value="<?php echo $names3[1];?>" /> 
                    </td>
                </tr>
                <?php }?>    
            </TABLE>
            </td>
            </tr>
          <tr>
            <td align="center" valign="middle">
            <INPUT type="button"  style="color:#FFF; background-color:#CB4B41; border:#FFF solid 1px; width:20px;" value="-" onclick="deleteRow('dataTable3')" />
            </td>
            <td colspan="3" align="center" valign="middle" class="font12" style="font-size:10px; color:#999;">
              <span style="float:left;">selected will be remove</span>
              <INPUT type="button" style="color:#FFF; background-color:#CB4B41; border:#FFF solid 1px; width:20px; " value="+" onclick="addRow('dataTable3')" />
            </td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td colspan="4" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td height="1" colspan="4" align="left" valign="middle" bgcolor="#CB4B41"></td>
        </tr>
        <tr>
        <td colspan="4" align="left" height="10" valign="middle"></td>
      </tr>
      <tr>
        <td colspan="4" align="center" valign="middle">
        <input type="submit" name="Submitwebsite" class="buttonbg" style="width:180px;" value="Generate References" /></td>
      </tr>
      </table>
      </form>
      </div>
      <?php
      $comp = ($_GET['_t']=="comp")? "block" : "none";
	  ?>
      <div id="menu4" style="display:<?php echo $comp;?>;">
      <form action="" method="post" name="form4">
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="borders" style="border:1px solid #FCB90F;">
      <tr>
        <td height="25" align="center" valign="middle" bgcolor="#F0F0F0" class="font12" onclick="show('1');" style="cursor:pointer;">
        <img src="./images/book.png" border="0" /></td>
        <td align="center" valign="middle" bgcolor="#F0F0F0" class="font12" onclick="show('2');" style="cursor:pointer;">
        <img src="./images/journal.png" border="0" /></td>
        <td align="center" valign="middle" bgcolor="#F0F0F0" class="font12" onclick="show('3');" style="cursor:pointer;">
        <img src="./images/website.png" border="0" /></td>
        <td align="center" valign="middle" bgcolor="#F0F0F0" class="font12" style="cursor:pointer;">
        <?php if(isset($_SESSION['user_id'])){?>
        <a href="index.php?page=assignment_manager&view=add_assign"><img src="./images/compose.png" border="0" /></a>
        <?php }else{?>
        <a href="#" id="buttonpopup6" class="hyberlik1"><img src="./images/compose.png" border="0" /></a>
        <?php }?></td>
      </tr>
      <tr>
        <td width="21%" height="25" align="center" valign="middle" bgcolor="#F0F0F0" class="font12">Book</td>
        <td width="27%" align="center" valign="middle" bgcolor="#F0F0F0" class="font12">Journal article</td>
        <td width="24%" align="center" valign="middle" bgcolor="#F0F0F0" class="font12">Website </td>
        <td width="28%" align="center" valign="middle" bgcolor="#F0F0F0" class="font12" style="color:#FCB90F;"><strong>Compose assignment</strong></td>
        </tr>
      <tr>
        <td colspan="4" align="left" valign="middle" class="font12">&nbsp;</td>
      </tr>
      <tr>
        <td height="30" colspan="4" align="left" valign="middle" class="font12">
        <?php
		/* $get = explode(",",$_GET['ids']);
		$cut = count($get);
		for($i=0;$i<$cut;$i++){
        $count=mysql_fetch_array(mysql_query("select * from composedocument where id='".$get[$i]."'"));
		$comments .= $count['comments']."<br /><br />";
		} */
		/* $citationlist = mysql_query("select CONCAT(  '<b>', lastname,  ', ', firstname,  '</b><br>', booktitle,  ', (', pyear,  ')' ) AS citation,  CONCAT('(',lastname,', ',pyear,')') as citationToInsert from composedocument where username='".$_SESSION['user_id']."' and types!='compose' order by id DESC");
		$citationListForJS = "\"[{";
		$i = 1;
		$citationListToInsertForJS = "\"";
		while($citation = mysql_fetch_array($citationlist)){
			$citationListForJS .= "'citation_".$i."':'".$citation['citation']."',";
			$citationListToInsertForJS .= "'".$citation['citationToInsert']."',";
			$i++;
		}
		$citationListForJS = substr($citationListForJS,0,(strlen($citationListForJS)-1));
		$citationListToInsertForJS = substr($citationListToInsertForJS,0,(strlen($citationListToInsertForJS)-1));
		$citationListForJS .= "}]\"";
		$citationListToInsertForJS .= "\"";
		echo "<script>citationList = ".$citationListForJS.";citationToInsert = ".$citationListToInsertForJS.";</script>"; */
		
		//Separate Code for editing document
		$get = explode(",",$ids);
		$count = count($get);
		if(count > 0)
		{
			$rs=mysql_fetch_array(mysql_query("select * from composedocument where id='".$get[0]."'"));
			$comments = $rs['comments']."<br /><br />";
		}
		?>
        <textarea name="area1" id="area1" class="txt-200" cols="50" style="height:200px; width:760px;"><?php echo $comments;?></textarea>
		
        </td>
        </tr>
      <tr>
        <td colspan="4" align="right" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td height="1" colspan="4" align="left" valign="middle" bgcolor="#FCB90F"></td>
        </tr>
        <tr>
        <td colspan="4" align="left" height="10" valign="middle"></td>
      </tr>
      <tr>
        <td colspan="4" align="center" valign="middle">
        <input type="submit" name="SubmitCompose" class="buttonbg" style="width:180px;" value="Submit Assignment" /></td>
      </tr>
      </table>
      </form>
      </div>
      </td>
    <td width="30%" rowspan="2" align="center" valign="top" class="font12">
    <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td height="30" colspan="3" align="center" valign="middle" id="radientbox" class="font12">
        	<div id="txt_title" style="display:''"><b><?php echo $title_reference; ?></b><a href="#" onclick="show_txt_title();">&nbsp;&nbsp;<img src="./images/edit.jpg" border="0" title="EDIT" alt="EDIT" /></a></div>
            <div id="txt_title2" style="display:none"><input type="text" id="text_title" name="text_title" value="<?php echo $title_reference; ?>" />&nbsp;&nbsp;<input type="button" name="btn_title" value="OK" onclick="edit_txt_title();" /></div>
        </td>
      </tr>
      <tr>
        <td colspan="3" align="left" valign="middle">
      <div class="borders" style="height:300px; background-color:#FFF; overflow:auto; border-top:none;">
      <div id="DelReference">
	  <!-- begin new citation for save to account -->    
      <?php
			include_once 'citation_list.php';
	  ?>
    <!-- end new citation for save to account -->
	</div>
    </div>
        </td>
      </tr>
      <tr>
        <td colspan="3" align="left" valign="middle">&nbsp;</td>
      </tr>
      <tr>
        <td height="55" colspan="3" align="center" valign="middle" class="font12">
        <?php if(isset($_SESSION['user_id'])){?>
        <A href="download.php"><img src="./images/download-icon.png" border="0" /></A>
        <?php }else{?>
        <a href="#" id="buttonpopup" class="hyberlik1"><img src="./images/download-icon.png" border="0" /></a>
        <?php }?>
        </td>
      </tr>
      <tr>
      	<td>
      		<div class="VideoBoxAssignment">
        	<?php 
	        $qry = "select * from video WHERE id = '2'";
			$res = $base_obj->exec_query($qry);
			$data = $base_obj->fetch_row($res);
		   	echo $data['url']; ?>
      	</td>      	        
        </div>
      </tr>
    </table>
    </td>
  </tr>
  <tr>
    <td align="center" valign="middle">&nbsp;</td>
    </tr>
  <tr>
    <td id="tdResourceCentre2" align="center" valign="top" class="font12">&nbsp;</td>
    <td align="center" valign="middle">&nbsp;</td>
    <td align="center" valign="top" class="font12">&nbsp;</td>
  </tr>
  <tr>
    <td id="tdResourceCentre3" align="center" valign="top" class="font12">&nbsp;</td>
    <td align="center" valign="middle">&nbsp;</td>
    <td align="center" valign="top" class="font12">&nbsp;</td>
  </tr>
        </table>
   	</div>      
      
     
      <!-- End contentwarp -->
       <?php include("includes/right_content.php");?>
      <div style="clear:both;"></div>
      
    </div>
    <!-- End mainWarpArea -->
  </div>
 <!-- Starting add guest popup window -->
          <div id="popupContact" style="width:550px; height:250px;">
            <a id="popupContactClose"><img src="images/close.gif" border="0" alt="Close" title="Close" /></a>
       <div id="Parent_Content"> 
            <form action="" method="post" name="form1">
              <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <td colspan="4" align="left" valign="middle">&nbsp;</td>
                </tr>
                <tr>
                  <td height="40" colspan="4" align="center" valign="middle" class="titles">
                  You need to be logged into an account to access this feature.
                  </td>
                </tr>
                <tr>
                  <td height="40" colspan="4" align="center" valign="middle" class="font12">&nbsp;</td>
                </tr>
                <tr>
                  <td height="40" colspan="4" align="center" valign="middle" class="font12">
                  Do you have an account with Studysage?
                  </td>
                </tr>
                <tr>
                  <td colspan="4" align="center" valign="middle" class="font12">&nbsp;</td>
                </tr>
                <tr>
                  <td width="18%" height="30" align="center" valign="middle">&nbsp;</td>
                  <td width="32%" align="center" valign="middle" class="font12">
                  <a  onclick="javascript: return login_Box();"href="javascript:void(0);" class="buttonbg" style="padding:5px 5px 5px 5px;">Yes, log me in</a></td>
                  <td width="32%" align="center" valign="middle" class="font12">
                  <a  onclick="javascript: return Signup_Box();" href="javascript:void(0);"  class="buttonbg" style="padding:5px 5px 5px 5px;">Sign me up</a></td>
                  <td width="18%" align="center" valign="middle">&nbsp;</td>
                </tr>
                <tr>
                  <td height="30" colspan="4" align="center" valign="middle" class="font12">&nbsp;</td>
                </tr>
                <tr>
                  <td height="30" colspan="4" align="center" valign="middle">&nbsp;</td>
                </tr>
              </table>
              </form></div>
     
            <div id="loinbox" style="display:none; margin-top:5%">
           
           <form action="" name="login"  method="post" onsubmit="return signin();">
          		<table height="100%" width="50%"   align="center" border="0" cellpadding="0" cellspacing="0">
                <tr>
                <td colspan="2">
                <span style="font-size:15px; font-family:Arial; font-weight:bold; color:#2580A2;" >Log In</span>
                </td>
                <td>
                 <div align="center" id="error_msg" style="color:#F00; font-size:14px;" ></div>
                </td>
                
                </tr>
                 
                <tr>
                <td width="41%" height="50" align="left" valign="middle" class="font12">E mail</td>
                <td width="7%" align="center" valign="middle" class="red">*</td>
                <td width="52%" align="left" valign="middle">
                <input type="text" name="email" id="email" />
                </td>
              </tr>
              <tr>
                <td height="50" align="left" valign="middle" class="font12">PassWord</td>
                <td align="center" valign="middle" class="red">*</td>
                <td align="left" valign="middle">
                <input name="password" id="password" type="password" /></td>
              </tr>
             
               </tr>
              <tr>
                <td height="25" align="left" valign="middle" class="font12"></td>
                <td align="center" valign="middle" class="red">
                 
                </td>
                <td align="left" valign="middle">
                 <input type="submit" name="Login" class="buttonbg" value="Log In" />
                 <input type="hidden" name="process" id="process" value=""/>
                 <input type="hidden" name="module" id="module" value="userlogin"/>
                </td>
              </tr>
             
             
               
            </table></form>
            </div>
            <div id="SignUpbox" style="display:none">
            <form action="" method="post" enctype="multipart/form-data"  name="reg_user_box" onsubmit="return validateReg_box();" autocomplete="off">
           			<table width="99%" align="center">
        <tbody><tr>
          <td colspan="3" valign="middle" align="left"><div id="error_msg" style="color:#F00; width:300px;">
          
          
          </div></td>
          </tr>
           <tr height="35">
            <td valign="middle" align="left">&nbsp;</td>
            <td style="padding-left: 20px;" class="font12" valign="middle" align="left">First Name</td>
          <td valign="middle" align="left">
          <input class="txtborder" id="fname" name="fname" style="width: 200px;" type="text">
             </td>
        </tr>     
       
        <tr height="35">
            <td valign="middle" align="left">&nbsp;</td>
            <td style="padding-left: 20px;" class="font12" valign="middle" align="left">Password</td>
          <td valign="middle" align="left">
          <input class="txtborder" id="passwd" name="passwd" style="width: 200px;" type="password">
          </td>
        </tr>
        <tr height="35">
            <td valign="middle" align="left">&nbsp;</td>
            <td style="padding-left: 20px;" class="font12" valign="middle" align="left">Email</td>
          <td valign="middle" align="left">
          <input class="txtborder" id="email_val" name="email_val" style="width: 200px;" type="text">
          </td>
        </tr> 
		<tr height="35">
            <td valign="middle" align="left">&nbsp;</td>
            <td style="padding-left: 20px;" class="font12" valign="middle" align="left">Student Email</td>
          <td valign="middle" align="left">
          <input class="txtborder" id="studentemail_val" name="studentemail_val" style="width: 200px;" type="text">
          </td>
        </tr>
        <tr height="35">
            <td valign="middle" align="left">&nbsp;</td>
            <td style="padding-left: 20px;" class="font12" valign="middle" align="left">What best describes you?</td>
          <td valign="middle" align="left">
          <select name="user_type" id="user_type" class="txtborder" style="width:210px;">
  				<option value="High School">High school student</option>
  				<option value="College Undergrad">Undergraduate college student</option>
  				<option value="College Grad">Graduate college student</option>
  				<option value="PHD">PHD student</option>
  				<option value="Teacher">Teacher/professor</option>
  				<option value="Researcher">Researcher</option>
  				<option value="Librarian">Librarian</option>
  				<option value="Other">Other</option>
  			</select></td>
        </tr>
        
        <tr height="35">
            <td valign="middle" align="left">&nbsp;</td>
            <td style="padding-left: 20px;" class="font12" valign="middle" align="left">Security code</td>
          <td valign="top" align="left">
          <input id="security_code" class="txtborder" name="security_code" style="width:100px;" type="text"   />
       <img src="includes/CaptchaSecurityImages.php?width=60&height=25&characters=5" />
          </td>
        </tr>
         
        <tr>
            <td align="left" valign="middle">&nbsp;</td>
            <td colspan="2" align="left" valign="middle" class="font12" style="padding-left: 20px;">
          <span id="per">  <input name="parent_permission" id="parent_permission" type="checkbox" value="1" /> </span>I am 13 years or older or have permission from my parents.
            </td>
          </tr>
         <tr>
            <td colspan="3" align="left" valign="middle"></td>
            </tr>   
        <tr height="35">
            <td colspan="2" valign="middle" align="left"></td>
          <td valign="middle" align="left">
          <input class="registerbutton" value="" name="register" type="submit">
          <input type="hidden" name="process"  id="process" value="add_user_box"/>
          <input type="hidden" name="module"  id="module" value="register_box"/>
        </td>
        </tr>
    </tbody></table></form>
            </div>
       	  </div>
            <div id="backgroundPopup"></div>			
            <!-- End of add guest popup window -->  
<script language="javascript">

function login_Box()
{
	$("#Parent_Content").css("display","none");
	$("#loinbox").fadeIn("slow");
}
function Signup_Box()
{
	$("#Parent_Content").css("display","none");
	$("#SignUpbox").fadeIn("slow");
	
}
</script>